import 'package:flutter/material.dart';

class MyApp20 extends StatelessWidget {
  const MyApp20({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('GridView的extend函数使用'),
        backgroundColor: Colors.red,
      ),
      //GridView.extent: 只能设置GridView元素的宽度
      body: GridView.extent(
        maxCrossAxisExtent: 100,
        mainAxisSpacing: 10,
        crossAxisSpacing: 10,
        childAspectRatio: 1,
        children: [
          Container(
            color: const Color.fromARGB(255, 229, 178, 238),
          ),
          Container(
            color: const Color.fromARGB(255, 178, 212, 238),
          ),
          Container(
            color: const Color.fromARGB(255, 178, 238, 179),
          ),
          Container(
            color: const Color.fromARGB(255, 238, 208, 178),
          ),
          Container(
            color: const Color.fromARGB(255, 238, 178, 197),
          ),
        ],
      ),
    );
  }
}
